Node

A single Node within a syntax Tree.

extern (C)
struct Node {}

Constructors

this
this(TSNode tsnode)

Create a new Node.

Members

Aliases

to_sexp
alias to_sexp = to_string
Undocumented in source.

Functions

byte_range
auto byte_range()

Get the byte range of source code that this node represents.

child
auto child(size_t child_index)

Get the node's child at the given index, where zero represents the first child.

child_by_field_id
auto child_by_field_id(ushort field_id)

Get the first child with the given field name.

child_by_field_name
auto child_by_field_name(string field_name)

Get the first child with the given field name.

child_count
auto child_count()

Get this node's number of children

children
auto children(TreeCursor* cursor)

Iterate over this node children.

children_by_field_id
auto children_by_field_id(ushort field_id, TreeCursor* cursor)

Iterate over this node children with a given field id.

children_by_field_name
auto children_by_field_name(string field_name, TreeCursor* cursor)

Iterate over this node children with a given field name.

descendant_for_byte_range
auto descendant_for_byte_range(uint start, uint end)

Get the smallest node within this node that spans the given range.

descendant_for_point_range
auto descendant_for_point_range(Point start, Point end)

Get the smallest node within this node that spans the given range.

edit
auto edit(InputEdit* edit)

Edit this node to keep it in-sync with source code that has been edited.

end_byte
auto end_byte()

Get the byte offsets where this node end.

end_position
auto end_position()

Get this node's end position in terms of rows and columns.

has_changes
auto has_changes()

Check if this node has been edited

has_error
auto has_error()

Check if this node represents a syntax error or contains any syntax errors anywhere within it.

has_next_sibling
auto has_next_sibling()

Check if the node has a next sibling. Note: next_sibling method already does this check

has_parent
auto has_parent()

Check if the node has a immediate parent Note: parent method already does this check

has_prev_sibling
auto has_prev_sibling()

Check if the node has a previous sibling. Note: prev_sibling method already does this check

hash
auto hash()

Hash a node. This returns a unique string for this node.

id
auto id()

Get a numeric id for this node that is unique.

isNull
bool isNull()

Check if the Node is a null node.

is_error
auto is_error()

Check if this node represents a syntax error.

is_extra
auto is_extra()

Check if this node is *extra*.

is_missing
auto is_missing()

Check if this node is *missing*.

is_named
auto is_named()

Check if this node is *named*.

kind
auto kind()

Get this node's type as a string.

kind_id
auto kind_id()

Get this node's type as a numerical id.

language
auto language()

Get the Language that was used to parse this node's syntax tree.

named_child
auto named_child(size_t i)

Get this node's *named* child at the given index.

named_child_count
auto named_child_count()

Get this node's number of *named* children.

named_children
auto named_children(TreeCursor* cursor)

Iterate over this node named children.

named_descendant_for_byte_range
auto named_descendant_for_byte_range(uint start, uint end)

Get the smallest named node within this node that spans the given range.

named_descendant_for_point_range
auto named_descendant_for_point_range(Point start, Point end)

Get the smallest named node within this node that spans the given range.

next_named_sibling
auto next_named_sibling()

Get this node next named sibling.

next_sibling
auto next_sibling()

Get this node next sibling.

nth_parent
auto nth_parent(uint max_nth)

Find the nth parent of node. It goes up until it hits a null parent or max_nth.

parent
auto parent()

Get this node immediate parent.

prev_named_sibling
auto prev_named_sibling()

Get this node previous named sibling.

prev_sibling
auto prev_sibling()

Get this node previous sibling.

range
auto range()

Get the range of source code that this node represents, both in terms of raw bytes and of row/column coordinates.

start_byte
auto start_byte()

Get the byte offsets where this node starts

start_position
auto start_position()

Get this node's start position in terms of rows and columns.

to_string
auto to_string()

Convert Node to string

traverse
void traverse(TreeVisitor visitor)

Traverse this Node and all its descendants in a top-down left to right manner while applying the visitor at each Node.

traverse_nothrow
void traverse_nothrow(TreeVisitor visitor)

Traverse this Node and all its descendants in a top-down left to right manner while applying the visitor at each Node.

utf16_text
auto utf16_text(ushort[] source)

Convert Node to utf16 string

utf8_text
auto utf8_text(string source_code)
auto utf8_text(ubyte[] source)

Convert Node to utf8 string

walk
auto walk()

Create a new TreeCursor starting from this node.

Static functions

create
Nullable!Node create(TSNode tsnode)

Creates a new Node from the given nullable TSNode

Variables

tsnode
TSNode tsnode;

The internal TSNode

Meta